home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _63796D61F2D24D28AD6ED46D5473AD98 < prev    next >
Text File  |  2005-02-12  |  1KB  |  59 lines

  1. //wake in water particle shader
  2. //Luke Lenhart
  3. //(C)2004-2005 Digipen Institute of Technology
  4.  
  5. //input position:
  6. //x,y = side of particle (either -1 or 1)
  7. //z = size of particle
  8.  
  9. //input vertex color:
  10. //a = alpha;
  11. //r(x) = x direction of wake
  12. //g(y) = y direction of wake
  13. //b = rotation angle of particle
  14.  
  15. //input tex coord = position in space
  16.  
  17. //world,view,projection transform
  18. float4x4 matViewProj;
  19.  
  20. //shader input
  21. struct VS_INPUT
  22. {
  23.     float4 Pos : POSITION;
  24.     float4 Clr : COLOR;
  25.     float2 Trans : TEXCOORD0;
  26. };
  27.  
  28. //shader output
  29. struct VS_OUTPUT
  30. {
  31.     float4 Pos : POSITION;
  32.     float2 Tex : TEXCOORD0;
  33.     float4 Clr : COLOR;
  34. };
  35.  
  36. //shader code
  37. VS_OUTPUT VShader(VS_INPUT In)
  38. {
  39.     VS_OUTPUT Out;
  40.     
  41.     //rotate and scale particle (model space)
  42.     In.Clr.b*=3.14159*2;
  43.     float2x2 matRot={cos(In.Clr.b),sin(In.Clr.b),-sin(In.Clr.b),cos(In.Clr.b)};
  44.     float4 pos;
  45.     pos.xy=mul(matRot,In.Pos.xy)*In.Pos.z;
  46.     pos.z=pos.w=1;
  47.     
  48.     //translate and transform it
  49.     pos.xy+=In.Trans;
  50.     Out.Pos=mul(matViewProj,pos);
  51.     Out.Tex=In.Pos.xy*0.5f + 0.5f;
  52.     
  53.     //make color of wake
  54.     Out.Clr=float4(1,1,1,In.Clr.a);
  55.  
  56.     //spit out the results
  57.     return Out;
  58. }
  59.